package abstractClass

/**
  * Vehicle
  *
  * @author zhangyimin
  * @date 2018-09-17 下午2:13
  * @version 1.0
  */
abstract class Vehicle {

  //抽象字段,这个字段只有get方法
  val id:Int
  //抽象字段,这个字段有get和set方法
  var name:String
  //抽象方法
  def getVehicle:String

}

//没有给属性赋值,但是写了主构造方法
class Car(val id:Int,var name:String) extends Vehicle{
  override def getVehicle: String = "I'm a car!"
}

//抽象属性和抽象方法都被实现
class Ship extends  Vehicle {
  val id:Int=10086
  var name:String="I'm a ship!"
  override def getVehicle: String = name
}

//抽象子类继承抽象父类
//这个是爹类,继承的是爷类
abstract class CarObject extends Vehicle{
  val id:Int
  var name:String
  def getCarName:String
}

//抽象孙类继承抽象爹类,并且必须实现爹类和爷类的抽象方法
class Audi(val id:Int,var name:String) extends CarObject{
  override def getCarName: String = "I'm a Audi!"
  override def getVehicle: String = "I'm a Car!"
}











